package ibmetp.mis.controller.sysparam;

import ibmetp.mis.common.Constants;
import ibmetp.mis.common.Message;
import ibmetp.mis.service.SysParamService;
import ibmetp.mis.service.UserService;
import ibmetp.mis.serviceImpl.SysParamServiceImpl;
import ibmetp.mis.serviceImpl.UserServiceImpl;
import ibmetp.mis.vo.SysParam;
import ibmetp.mis.vo.User;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

/**
 * Servlet implementation class updateSysParamservlet
 */
public class SysParamUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SysParamUpdateServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding(Constants.ENCODING_UTF8);
		System.out.println("Call SysparamUpdateServlet...");
		
		//获取参数
		SysParam sysparam=new SysParam();
//		sysparam.setSysparamId(Long.parseLong(request.getParameter("paramId")));
		sysparam.setSysparamName(request.getParameter("paramName"));
		sysparam.setValue(request.getParameter("value"));
		sysparam.setCategory(request.getParameter("category"));
		System.out.println(request.getParameter("category"));
		sysparam.setSysparamId(Long.valueOf(request.getParameter("paramId")));
		
		//添加系统参数
		SysParamService ss=new SysParamServiceImpl();
		String result=ss.updateSysParam(sysparam);
		
		if(result!=null){		
			response.setCharacterEncoding(Constants.ENCODING_UTF8);
			response.getWriter().print(JSONObject.fromObject(new Message(result)));
		}
		
	}
}
